#ifndef FRAMEMODEL_H
#define FRAMEMODEL_H

#include <QAbstractListModel>
#include "animationdatahandler.h"
#include "action.h"
#include "CommonMarcro.h"
#include <QItemSelection>
#include <QDebug>

class FrameModel : public QAbstractListModel
{
    Q_OBJECT
public:
    FrameModel(AnimationDataHandler* coreData, QObject* parent = 0);
    ~FrameModel();

    QVariant data(const QModelIndex &index, int role) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    QVariant headerData(int section, Qt::Orientation orientation,
                                int role = Qt::DisplayRole) const;

    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;

    void appendFrameList(const PlistFrameInfoList& frameList);
    void removeFrameByIndexList(QModelIndex& index);

    QModelIndex getCurrentFrameIndex();
    QModelIndex getFrameModelIndexbyIndex(int row);

public slots:
    void selectChanged(const QItemSelection& selected,const QItemSelection& desSelected);
    void dataChangeUpdate();

private:
    int getOverZeroValue(int value);
    bool isValidIndex(QModelIndex index) const;

private:
    AnimationDataHandler* m_coreData;

private:
    static const int MAX_COLUMN_NUM;
};

#endif // FRAMEMODEL_H
